<template>
  <el-container id="layout">
    <el-header style="text-align: right; font-size: 12px">
      <el-dropdown>
        <i class="el-icon-setting"
           style="margin-right: 15px"></i>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>查看</el-dropdown-item>
            <el-dropdown-item>新增</el-dropdown-item>
            <el-dropdown-item>删除</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
      <span>王小虎</span>
    </el-header>
    <el-container>
      <el-aside width="200px"
                style="background-color: rgb(238, 241, 246)">
        <el-menu :default-openeds="['1']">
          <el-submenu index="1">
            <template #title><i class="el-icon-message"></i>组件菜单</template>
            <el-menu-item-group>
              <el-menu-item v-for="elementTag in elementTags"
                            :index="elementTag.tagName"
                            :key="elementTag.tagName"
                            v-drag="{attr:elementTag,draggable:true}">
                {{elementTag.name}}
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container>
        <design-area />
      </el-container>
      <el-aside width="300px"
                style="background-color: rgb(238, 241, 246)">
        <attr-area />
      </el-aside>
    </el-container>

  </el-container>
</template>

<script>
import axios from 'axios';
import { onMounted, ref } from 'vue';
import DesignArea from './DesignArea.vue';
import AttrArea from './AttrArea.vue';

export default {
  components: {
    DesignArea,
    AttrArea,
  },
  setup () {
    const elementTags = ref({});
    onMounted(() => {
      axios.get('/tags.json').then((res) => {
        elementTags.value = res.data;
      });
    });
    return {
      elementTags,
    };
  },
};
</script>

<style lang="scss" scoped>
#layout {
  height: 100vh;
}
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
</style>
